<!DOCTYPE html>



  


<html class="theme-next gemini use-motion" lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
















  
  
  <link href="/blog/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">







<link href="/blog/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="/blog/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/blog/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/blog/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/blog/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/blog/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="垃圾回收器,类加载机制,">










<meta name="description" content="在上一篇深入理解jvm虚拟机一中说了Jvm几种垃圾回收算法，针对年代不同，Jvm为我们提供了几种垃圾收集器。 垃圾收集器Java为我们提供了很多垃圾收集器，Young为新生代所选择的，Tenured为老年代所选，可以相互配合使用，没有最好的收集器，只有最适合的。如图所示： Serial（单线程、复制算法）Serial是最基本的垃圾回收器，它是一个单线程的收集器，不但只会使用一个CPU或一条线程去完">
<meta name="keywords" content="垃圾回收器,类加载机制">
<meta property="og:type" content="article">
<meta property="og:title" content="深入理解Jvm虚拟机二">
<meta property="og:url" content="https://zgsir.gitee.io/blog/2019/05/21/深入理解Jvm虚拟机二/index.html">
<meta property="og:site_name" content="zhaoSir">
<meta property="og:description" content="在上一篇深入理解jvm虚拟机一中说了Jvm几种垃圾回收算法，针对年代不同，Jvm为我们提供了几种垃圾收集器。 垃圾收集器Java为我们提供了很多垃圾收集器，Young为新生代所选择的，Tenured为老年代所选，可以相互配合使用，没有最好的收集器，只有最适合的。如图所示： Serial（单线程、复制算法）Serial是最基本的垃圾回收器，它是一个单线程的收集器，不但只会使用一个CPU或一条线程去完">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="https://s2.ax1x.com/2019/05/25/VF5msf.png">
<meta property="og:image" content="https://s2.ax1x.com/2019/05/25/VF5iIH.png">
<meta property="og:image" content="https://s2.ax1x.com/2019/05/25/VF5pqO.png">
<meta property="og:image" content="https://s2.ax1x.com/2019/05/25/VF5Pde.png">
<meta property="og:image" content="https://s2.ax1x.com/2019/05/25/VF5SsK.png">
<meta property="og:image" content="https://s2.ax1x.com/2019/05/25/VF5CZD.png">
<meta property="og:image" content="https://s2.ax1x.com/2019/05/25/VF5kid.png">
<meta property="og:image" content="https://s2.ax1x.com/2019/05/25/VF5AJA.png">
<meta property="og:image" content="https://s2.ax1x.com/2019/05/25/VF5ERI.png">
<meta property="og:image" content="https://s2.ax1x.com/2019/05/25/VF5Vzt.png">
<meta property="og:image" content="https://s2.ax1x.com/2019/05/25/VF5eQP.png">
<meta property="og:image" content="https://s2.ax1x.com/2019/05/25/VF5nL8.png">
<meta property="og:image" content="https://s2.ax1x.com/2019/05/25/VF5KeS.png">
<meta property="og:updated_time" content="2019-05-26T14:44:36.383Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="深入理解Jvm虚拟机二">
<meta name="twitter:description" content="在上一篇深入理解jvm虚拟机一中说了Jvm几种垃圾回收算法，针对年代不同，Jvm为我们提供了几种垃圾收集器。 垃圾收集器Java为我们提供了很多垃圾收集器，Young为新生代所选择的，Tenured为老年代所选，可以相互配合使用，没有最好的收集器，只有最适合的。如图所示： Serial（单线程、复制算法）Serial是最基本的垃圾回收器，它是一个单线程的收集器，不但只会使用一个CPU或一条线程去完">
<meta name="twitter:image" content="https://s2.ax1x.com/2019/05/25/VF5msf.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/blog/',
    scheme: 'Gemini',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://zgsir.gitee.io/blog/2019/05/21/深入理解Jvm虚拟机二/">





  <title>深入理解Jvm虚拟机二 | zhaoSir</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/blog/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">zhaoSir</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">一个不正经的后台开发攻城狮</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/blog/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/blog/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br>
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/blog/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br>
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/blog/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br>
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/blog/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
            
            归档
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br>
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocomplete="off" placeholder="搜索..." spellcheck="false" type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://zgsir.gitee.io/blog/blog/2019/05/21/深入理解Jvm虚拟机二/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="zhaoSir">
      <meta itemprop="description" content>
      <meta itemprop="image" content="/blog/images/head.jpeg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="zhaoSir">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">深入理解Jvm虚拟机二</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-05-21T15:45:58+08:00">
                2019-05-21
              </time>
            

            
              <span class="post-meta-divider">|</span>
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-check-o"></i>
              </span>
              
                <span class="post-meta-item-text">更新于&#58;</span>
              
              <time title="更新于" itemprop="dateModified" datetime="2019-05-26T22:44:36+08:00">
                2019-05-26
              </time>
            
          </span>
          
          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/Jvm/" itemprop="url" rel="index">
                    <span itemprop="name">Jvm</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          
            <span class="post-meta-divider">|</span>
            <span class="page-pv"><i class="fa fa-eye"></i> 阅读
            <span class="busuanzi-value" id="busuanzi_value_page_pv"></span>次
            </span>
          

          
            <div class="post-wordcount">
              
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  2.7k
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  9分钟
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>在上一篇<strong>深入理解jvm虚拟机一</strong>中说了Jvm几种垃圾回收算法，针对年代不同，Jvm为我们提供了几种垃圾收集器。</p>
<h1 id="垃圾收集器"><a href="#垃圾收集器" class="headerlink" title="垃圾收集器"></a>垃圾收集器</h1><p>Java为我们提供了很多垃圾收集器，Young为新生代所选择的，Tenured为老年代所选，可以相互配合使用，没有最好的收集器，只有最适合的。如图所示：<br><img src="https://s2.ax1x.com/2019/05/25/VF5msf.png" alt="GC回收器"></p>
<h2 id="Serial（单线程、复制算法）"><a href="#Serial（单线程、复制算法）" class="headerlink" title="Serial（单线程、复制算法）"></a>Serial（单线程、复制算法）</h2><p>Serial是最基本的垃圾回收器，它是一个单线程的收集器，不但只会使用一个CPU或一条线程去完成垃圾收集，更重要的是它在进行收集时，必须暂停其他所有的线程，直到垃圾回收完毕，因为不需要线程间切换，可以获得更高效的执行效率，因此<strong>它也是Java虚拟机运行在Client模式下默认新生代垃圾收集器</strong>。<br><img src="https://s2.ax1x.com/2019/05/25/VF5iIH.png" alt="Serial"></p>
<h2 id="ParNew（Serial-多线程）"><a href="#ParNew（Serial-多线程）" class="headerlink" title="ParNew（Serial+多线程）"></a>ParNew（Serial+多线程）</h2><p>ParNew其实是Serial多线程版本，也是使用复制算法，除了使用多线程进行垃圾收集以外，其他跟Serial一样，在进行垃圾收集过程中也需要停止所有其他线程操作，默认开启跟CPU数目相同的线程数（<strong>ParallelGCThreads</strong>设置数量）。<strong>它是多数Java虚拟机运行在Server模式下默认新生代垃圾收集器。</strong><br><img src="https://s2.ax1x.com/2019/05/25/VF5pqO.png" alt="ParNew"></p>
<h2 id="Parallel-Scavenge-（多线程复制算法、高效）"><a href="#Parallel-Scavenge-（多线程复制算法、高效）" class="headerlink" title="Parallel Scavenge （多线程复制算法、高效）"></a>Parallel Scavenge （多线程复制算法、高效）</h2><p>Parallel也是新生代的垃圾回收器，同样才用复制算法，但是它是重点<strong>关注一个可控制的吞吐量</strong>（CPU 用于运行用户代码<br>的时间/CPU 总消耗时间，即吞吐量=运行用户代码时间/(运行用户代码时间+垃圾收集时间)），可以有效提高CPU使用率，尽快的完成运算，偏向于后台计算而不需要太多交互，<strong>自适应调节策略也是 Parallel 与 ParNew 的一个重要区别</strong>。</p>
<h2 id="Serial-Old-（单线程标记整理算法-）"><a href="#Serial-Old-（单线程标记整理算法-）" class="headerlink" title="Serial Old （单线程标记整理算法 ）"></a>Serial Old （单线程标记整理算法 ）</h2><p>Serial Old是Serial垃圾收集器的老年代版本，同样是一个单线程的收集器，使用标记整理算法，主要是运行在Client模式下老年代的垃圾收集器，如果在Server模式下，还有两个功能：在 JDK1.5 之前版本中与新生代的 Parallel Scavenge 收集器搭配使用；作为年老代CMS备用垃圾收集器，在并发收集发生“Concurrent Mode Failure”时使用。<br><img src="https://s2.ax1x.com/2019/05/25/VF5Pde.png" alt="Serial Old"></p>
<h2 id="Parallel-Old-（多线程标记整理算法）"><a href="#Parallel-Old-（多线程标记整理算法）" class="headerlink" title="Parallel Old  （多线程标记整理算法）"></a>Parallel Old  （多线程标记整理算法）</h2><p>Parallel Old是Parallel老年代垃圾回收器，使用多线程标记整理算法，在Jdk1.6以前Parallel只能配合Serial Old使用，无法保证整体的吞吐量，Parallel Old 是为了提高老年代吞吐量而提供的。<br><img src="https://s2.ax1x.com/2019/05/25/VF5SsK.png" alt="Parallel Old"></p>
<h2 id="CMS（多线程标记清除算法）"><a href="#CMS（多线程标记清除算法）" class="headerlink" title="CMS（多线程标记清除算法）"></a>CMS（多线程标记清除算法）</h2><p>Concuuent mark sweep是一种年老代垃圾收集器，主要<strong>目标是获取最短垃圾回收停顿时间</strong>，和其他老年代标记整理不一样，它使用的多线程标记清除，最短垃圾回收停顿时间可以为频繁交互的程序提高用户体验。整个过程为以下四步</p>
<p> <strong>1. 初始标记：只是标记roots能直接关联到的对象，速度很快，需要暂停其他线程。</strong><br> <strong>2. 并发标记：进行roots跟踪的过程，和用户线程一起工作，不需要暂停其他线程。</strong><br> <strong>3. 重新标记：为了修正在并发标记时，用户操作产生变动的一部分对象引用标记记录，需要暂停其他线程。</strong><br> <strong>4. 并发清除：清除不可达对象，和用户线程一起工作，不需要暂停其他线程。</strong><br>由于是使用是标记清除，可能出现“<strong>Concurrent Mode Failure</strong>”失败而导致一次Full GC，由于CMS在并发清除的时候还会有垃圾进来，如果CMS预留空间无法满足程序需要，虚拟机就会启动备用方案：<strong>临时启用Serial old收集器回收老年代资源</strong>，这样停顿时间就会更长，因此还需要留有空间来存储垃圾，不能等到老年代被填满了在进行GC，设置<strong>CMSInitiatingOccupancyFraction</strong>（默认是92），只有达到这个峰值才会进行垃圾回收，配合<strong>UseCMSInitiatingOccupancyOnly</strong>一起使用，只有CMSInitiatingOccupancyFraction设置后才会生效，如果不指定CMSInitiatingOccupancyFraction，JVM仅在第一次使用设定值，后续则自动调整。<br><strong>CMS无法浮动垃圾会产生碎片</strong>，如果碎片很多，无法放入大对象，不得不提前触发一次Full GC，为了防止这种情况出现，CMS提供了<strong>UseCMSCompactAtFullConllection</strong>开关参数（默认开启），用于顶不住要Full GC的时候来进行内存碎片整合。由于碎片整合是无法并发的，空间问题解决了但是停顿时间就长了，还需要设置<strong>CMSFullGCBeforeCompaction</strong>（默认0次，表示每次次Full GC的时候都会压缩），这个参数设置多少次不压缩Full GC后，然后来一次带压缩的。<br><img src="https://s2.ax1x.com/2019/05/25/VF5CZD.png" alt="CMS"></p>
<h2 id="G1（多线程标记整理算法）"><a href="#G1（多线程标记整理算法）" class="headerlink" title="G1（多线程标记整理算法）"></a>G1（多线程标记整理算法）</h2><p>Garbage first（UseG1GC ）收集器是当今收集器技术发展的最前沿成果之一，它是一款面向服务端应用的垃圾回收器，相对比CMS，G1是两个优点：<strong>1.基于标记-整理，不会产生碎片。2.可以非常精确控制停顿时间（XX:MaxGCPauseMillis），在不牺牲吞吐量的情况下，实现低停顿垃圾回收</strong>。它将整个堆分为若干个大小相等的独立区域（Region）（Eden区 Survivor区 Old区 Humongous区）Humongous为放至巨型对象，虽然保留新生代和老年代概念，但是不再是物理隔离，它们都是一部分Region（不需要连续）的集合。<br><img src="https://s2.ax1x.com/2019/05/25/VF5kid.png" alt="G1"></p>
<h1 id="类加载机制"><a href="#类加载机制" class="headerlink" title="类加载机制"></a>类加载机制</h1><h2 id="加载时机"><a href="#加载时机" class="headerlink" title="加载时机"></a>加载时机</h2><p>类从加载到虚拟机内存中开始，到从内存中卸载，它的整个生命周期包括：<strong>加载、连接（验证、准备、解析）、初始化、使用、卸载。</strong> 加载、验证、准备、初始化和卸载这五个阶段的顺序是确定的，类加载必须按照这种顺序来加载，而解析就不一定了，它在某些情况下可以在初始化后再开始，符合Java语言的运行时绑定。<br><img src="https://s2.ax1x.com/2019/05/25/VF5AJA.png" alt="类加载"></p>
<h3 id="加载"><a href="#加载" class="headerlink" title="加载"></a>加载</h3><p><strong>会在内存中生成一个这个类的Class对象，作为方法区这个类的各种数据入口</strong>。这里的并不是从Class文件中获取，既可以从ZIP包中读取（jar、war），也可以在运行时动态生成，也可以从其他文件生成（JSP转为Class对象）。</p>
<h3 id="验证"><a href="#验证" class="headerlink" title="验证"></a>验证</h3><p><strong>是为了确保Class文件的字节流包含的信息是否符合当前虚拟机的要求，并且不会危害虚拟机自身</strong>。分为四个阶段完成：<br> <strong>1. 文件格式验证：验证字节流是否符合Class文件格式规范。</strong><br> <strong>2. 元数据验证：验证字节流的信息是否符合Java语言规范要求。</strong><br> <strong>3. 字节码验证：确定程序语义是合法的、符合逻辑的。</strong><br> <strong>4. 符合引用验证：对常量池中符号引用的信息进行匹配性校验。</strong></p>
<h3 id="准备"><a href="#准备" class="headerlink" title="准备"></a>准备</h3><p><strong>是为类变量分配内存并初始值的阶段。</strong> 类变量即被static修饰的变量，不包括实例变量。注意这里所说的初始值概念，比如一个类变量定义为：public static int a = 8080；实际上变量 a 在准备阶段过后的初始值为 0 而不是 8080，将 v 赋值为 8080 的 put static 指令是程序被编译后，存放于类构造器<strong>client</strong>方法之中。但是注意如果声明为：public static <strong>final</strong> int a = 8080；在编译阶段会为 a 生成 ConstantValue 属性，在准备阶段虚拟机会根据 ConstantValue 属性将 a 赋值为 8080。</p>
<h3 id="解析"><a href="#解析" class="headerlink" title="解析"></a>解析</h3><p><strong>虚拟机将常量池中的符合引用替换为直接引用</strong>。符号引用可以看成一个标识，比如一个方法、接口等，直接引用则是指向内存中的地址。</p>
<h3 id="初始化"><a href="#初始化" class="headerlink" title="初始化"></a>初始化</h3><p>类加载最后一个阶段，除了加载可以自定义累加器之外，其他都是由JVM自动完成，到了初始化阶段，才开始真正的执行类中Java代码。特别注意以下情况并<strong>不会触发初始化</strong>：<br> <strong>1. 通过子类引用父类的静态字段，只会触发父类的初始化，而不会触发子类的初始化。</strong><br> <strong>2. 定义对象数组，不会触发该类的初始化。</strong><br> <strong>3. 常量在编译期间会存入调用类的常量池中，本质上并没有直接引用定义常量的类，不会触发定义常量所在的类。</strong><br> <strong>4. 通过类名获取 Class 对象，不会触发类的初始化。</strong><br> <strong>5. 通过 Class.forName 加载指定类时，如果指定参数 initialize 为 false 时，也不会触发类初始化，其实这个参数是告诉虚拟机，是否要对类进行初始化。</strong><br> <strong>6. 通过 ClassLoader 默认的 loadClass 方法，也不会触发初始化动作。</strong></p>
<blockquote>
<p>第一种情况：<br><img src="https://s2.ax1x.com/2019/05/25/VF5ERI.png" alt="通过子类引用父类的静态字段，只会触发父类的初始化，而不会触发子类的初始化"><br>输出结果： I am father<br>                     1</p>
</blockquote>
<blockquote>
<p>第二种情况：<br><img src="https://s2.ax1x.com/2019/05/25/VF5Vzt.png" alt="定义对象数组，不会触发该类的初始化"><br>无任何输出</p>
</blockquote>
<blockquote>
<p>第三种情况<br><img src="https://s2.ax1x.com/2019/05/25/VF5eQP.png" alt="在这里插入图片描述"><br><img src="https://s2.ax1x.com/2019/05/25/VF5nL8.png" alt="在这里插入图片描述"><br>输出结果：1</p>
</blockquote>
<h2 id="类加载器"><a href="#类加载器" class="headerlink" title="类加载器"></a>类加载器</h2><p>对于一个类来说，都需要由加载它的类加载器和这个类本身一同确立在Java虚拟机中的唯一性。在比较两个类是否相等，只有在同一个类加载器加载的情况下才有意义。JVM提供了三种类加载器：</p>
<h3 id="启动类加载器（Bootstrap-ClassLoader）"><a href="#启动类加载器（Bootstrap-ClassLoader）" class="headerlink" title="启动类加载器（Bootstrap ClassLoader）"></a>启动类加载器（Bootstrap ClassLoader）</h3><p>负责加载JAVA_HOME\lib目录中的或通过设置-XbootClassPath参数指定的路径中的，并且是虚拟机识别（按文件名识别）的类库加载到虚拟机内存中。</p>
<h3 id="扩展类加载器（Extension-ClassLoader）"><a href="#扩展类加载器（Extension-ClassLoader）" class="headerlink" title="扩展类加载器（Extension ClassLoader）"></a>扩展类加载器（Extension ClassLoader）</h3><p>负责加载JAVA_HOME\lib\ext目录中的或者通过 java.ext.dirs系统变量指定路径中的类库。</p>
<h3 id="应用程序类加载器（Application-ClassLoader）"><a href="#应用程序类加载器（Application-ClassLoader）" class="headerlink" title="应用程序类加载器（Application ClassLoader）"></a>应用程序类加载器（Application ClassLoader）</h3><p>负责加载用户路径（ClassPath）下的类库。<br><strong>JVM通过双亲委派模型进行类加载</strong>，当然我们也可以继承ClassLoader实现自定义类加载器。<br><img src="https://s2.ax1x.com/2019/05/25/VF5KeS.png" alt="类加载器"></p>
<h1 id="双亲委派"><a href="#双亲委派" class="headerlink" title="双亲委派"></a>双亲委派</h1><p><strong>当一个类收到了类加载请求后，首先自己不会尝试加载，而是把这个请求交给父类加载，每一层类加载器都是如此，只有当父类无法加载子类才会尝试自己加载，不管是哪个加载器加载这个类，最终都委派给顶层的启动类加载器，这样就保证了使用不同类加载器得到的都是同一个对象，保证唯一性和安全性。</strong></p>

      
    </div>
    
    
    
	<div>
      
        
<div class="my_post_copyright">
  <script src="//cdn.bootcss.com/clipboard.js/1.5.10/clipboard.min.js"></script>
  
  <!-- JS库 sweetalert 可修改路径 -->
  <script src="https://cdn.bootcss.com/jquery/2.0.0/jquery.min.js"></script>
  <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
  <p><span>本文标题:</span><a href="/blog/2019/05/21/深入理解Jvm虚拟机二/">深入理解Jvm虚拟机二</a></p>
  <p><span>文章作者:</span><a href="/" title="访问 zhaoSir 的个人博客">zhaoSir</a></p>
  <p><span>发布时间:</span>2019年05月21日 - 15:45</p>
  <p><span>最后更新:</span>2019年05月26日 - 22:44</p>
  <p><span>原始链接:</span><a href="/blog/2019/05/21/深入理解Jvm虚拟机二/" title="深入理解Jvm虚拟机二">https://zgsir.gitee.io/blog/2019/05/21/深入理解Jvm虚拟机二/</a>
    <span class="copy-path" title="点击复制文章链接"><i class="fa fa-clipboard" data-clipboard-text="https://zgsir.gitee.io/blog/2019/05/21/深入理解Jvm虚拟机二/" aria-label="复制成功！"></i></span>
  </p>
  <p><span>许可协议:</span><i class="fa fa-creative-commons"></i> <a rel="license" href="https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank" title="Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)">署名-非商业性使用-禁止演绎 4.0 国际</a> 转载请保留原文链接及作者。</p>  
</div>
<script> 
    var clipboard = new Clipboard('.fa-clipboard');
      $(".fa-clipboard").click(function(){
      clipboard.on('success', function(){
        swal({   
          title: "",   
          text: '复制成功',
          icon: "success", 
          showConfirmButton: true
          });
        });
    });  
</script>

      
</div>
   <div>
    
    <div>
    
        <div style="text-align:center;color: #111;font-size:16px;">-------------------------------------本文结束<i class="fa fa-paw"></i>感谢您的阅读-------------------------------------</div>
    
</div>
    
    </div>
   

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/blog/tags/垃圾回收器/" rel="tag"><i class="fa fa-tag"> </i> 垃圾回收器</a>
          
            <a href="/blog/tags/类加载机制/" rel="tag"><i class="fa fa-tag"> </i> 类加载机制</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/blog/2019/05/21/深入理解Jvm虚拟机一/" rel="next" title="深入理解Jvm虚拟机一">
                <i class="fa fa-chevron-left"></i> 深入理解Jvm虚拟机一
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/blog/2019/05/22/Java并发编程一基础必知/" rel="prev" title="Java并发编程一基础必知">
                Java并发编程一基础必知 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  
    <div class="comments" id="comments">
      <div id="lv-container" data-id="city" data-uid="MTAyMC80NDMyMC8yMDg1Mw=="></div>
    </div>

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image" src="/blog/images/head.jpeg" alt="zhaoSir">
            
              <p class="site-author-name" itemprop="name">zhaoSir</p>
              <p class="site-description motion-element" itemprop="description">让人迷茫的原因的只有一个，那就是本该拼搏的年纪，想得太多，做得太少。</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/blog/archives/">
              
                  <span class="site-state-item-count">10</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/blog/categories/index.html">
                  <span class="site-state-item-count">2</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/blog/tags/index.html">
                  <span class="site-state-item-count">19</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#垃圾收集器"><span class="nav-number">1.</span> <span class="nav-text">垃圾收集器</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#Serial（单线程、复制算法）"><span class="nav-number">1.1.</span> <span class="nav-text">Serial（单线程、复制算法）</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#ParNew（Serial-多线程）"><span class="nav-number">1.2.</span> <span class="nav-text">ParNew（Serial+多线程）</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Parallel-Scavenge-（多线程复制算法、高效）"><span class="nav-number">1.3.</span> <span class="nav-text">Parallel Scavenge （多线程复制算法、高效）</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Serial-Old-（单线程标记整理算法-）"><span class="nav-number">1.4.</span> <span class="nav-text">Serial Old （单线程标记整理算法 ）</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Parallel-Old-（多线程标记整理算法）"><span class="nav-number">1.5.</span> <span class="nav-text">Parallel Old  （多线程标记整理算法）</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#CMS（多线程标记清除算法）"><span class="nav-number">1.6.</span> <span class="nav-text">CMS（多线程标记清除算法）</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#G1（多线程标记整理算法）"><span class="nav-number">1.7.</span> <span class="nav-text">G1（多线程标记整理算法）</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#类加载机制"><span class="nav-number">2.</span> <span class="nav-text">类加载机制</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#加载时机"><span class="nav-number">2.1.</span> <span class="nav-text">加载时机</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#加载"><span class="nav-number">2.1.1.</span> <span class="nav-text">加载</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#验证"><span class="nav-number">2.1.2.</span> <span class="nav-text">验证</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#准备"><span class="nav-number">2.1.3.</span> <span class="nav-text">准备</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#解析"><span class="nav-number">2.1.4.</span> <span class="nav-text">解析</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#初始化"><span class="nav-number">2.1.5.</span> <span class="nav-text">初始化</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#类加载器"><span class="nav-number">2.2.</span> <span class="nav-text">类加载器</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#启动类加载器（Bootstrap-ClassLoader）"><span class="nav-number">2.2.1.</span> <span class="nav-text">启动类加载器（Bootstrap ClassLoader）</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#扩展类加载器（Extension-ClassLoader）"><span class="nav-number">2.2.2.</span> <span class="nav-text">扩展类加载器（Extension ClassLoader）</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#应用程序类加载器（Application-ClassLoader）"><span class="nav-number">2.2.3.</span> <span class="nav-text">应用程序类加载器（Application ClassLoader）</span></a></li></ol></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#双亲委派"><span class="nav-number">3.</span> <span class="nav-text">双亲委派</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<script type="text/javascript" src="/blog/js/src/love.js"></script>
<div class="copyright">&copy; <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">zhaoSir</span>

  
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
    
      <span class="post-meta-item-text">博客字总数&#58;</span>
    
    <span title="博客字总数">20.8k</span>
  
  
</div>




        
<div class="busuanzi-count">
  <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  

  
</div>








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  


  











  
  
    <script type="text/javascript" src="/blog/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/canvas-nest/canvas-nest.min.js"></script>
  


  


  <script type="text/javascript" src="/blog/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/blog/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/blog/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/blog/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/blog/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/blog/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/blog/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  
    <script type="text/javascript">
      (function(d, s) {
        var j, e = d.getElementsByTagName(s)[0];
        if (typeof LivereTower === 'function') { return; }
        j = d.createElement(s);
        j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
        j.async = true;
        e.parentNode.insertBefore(j, e);
      })(document, 'script');
    </script>
  












  

  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    var isXml = true;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length === 0) {
      search_path = "search.xml";
    } else if (/json$/i.test(search_path)) {
      isXml = false;
    }
    var path = "/blog/" + search_path;
    // monitor main search box;

    var onPopupClose = function (e) {
      $('.popup').hide();
      $('#local-search-input').val('');
      $('.search-result-list').remove();
      $('#no-result').remove();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    }

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.search-popup-overlay').click(onPopupClose);
      $('.popup').toggle();
      var $localSearchInput = $('#local-search-input');
      $localSearchInput.attr("autocapitalize", "none");
      $localSearchInput.attr("autocorrect", "off");
      $localSearchInput.focus();
    }

    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';

      // start loading animation
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay">' +
          '<div id="search-loading-icon">' +
          '<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>' +
          '</div>' +
          '</div>')
        .css('overflow', 'hidden');
      $("#search-loading-icon").css('margin', '20% auto 0 auto').css('text-align', 'center');

      $.ajax({
        url: path,
        dataType: isXml ? "xml" : "json",
        async: true,
        success: function(res) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = isXml ? $("entry", res).map(function() {
            return {
              title: $("title", this).text(),
              content: $("content",this).text(),
              url: $("url" , this).text()
            };
          }).get() : res;
          var input = document.getElementById(search_id);
          var resultContent = document.getElementById(content_id);
          var inputEventFunction = function() {
            var searchText = input.value.trim().toLowerCase();
            var keywords = searchText.split(/[\s\-]+/);
            if (keywords.length > 1) {
              keywords.push(searchText);
            }
            var resultItems = [];
            if (searchText.length > 0) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var hitCount = 0;
                var searchTextCount = 0;
                var title = data.title.trim();
                var titleInLowerCase = title.toLowerCase();
                var content = data.content.trim().replace(/<[^>]+>/g,"");
                var contentInLowerCase = content.toLowerCase();
                var articleUrl = decodeURIComponent(data.url);
                var indexOfTitle = [];
                var indexOfContent = [];
                // only match articles with not empty titles
                if(title != '') {
                  keywords.forEach(function(keyword) {
                    function getIndexByWord(word, text, caseSensitive) {
                      var wordLen = word.length;
                      if (wordLen === 0) {
                        return [];
                      }
                      var startPosition = 0, position = [], index = [];
                      if (!caseSensitive) {
                        text = text.toLowerCase();
                        word = word.toLowerCase();
                      }
                      while ((position = text.indexOf(word, startPosition)) > -1) {
                        index.push({position: position, word: word});
                        startPosition = position + wordLen;
                      }
                      return index;
                    }

                    indexOfTitle = indexOfTitle.concat(getIndexByWord(keyword, titleInLowerCase, false));
                    indexOfContent = indexOfContent.concat(getIndexByWord(keyword, contentInLowerCase, false));
                  });
                  if (indexOfTitle.length > 0 || indexOfContent.length > 0) {
                    isMatch = true;
                    hitCount = indexOfTitle.length + indexOfContent.length;
                  }
                }

                // show search results

                if (isMatch) {
                  // sort index by position of keyword

                  [indexOfTitle, indexOfContent].forEach(function (index) {
                    index.sort(function (itemLeft, itemRight) {
                      if (itemRight.position !== itemLeft.position) {
                        return itemRight.position - itemLeft.position;
                      } else {
                        return itemLeft.word.length - itemRight.word.length;
                      }
                    });
                  });

                  // merge hits into slices

                  function mergeIntoSlice(text, start, end, index) {
                    var item = index[index.length - 1];
                    var position = item.position;
                    var word = item.word;
                    var hits = [];
                    var searchTextCountInSlice = 0;
                    while (position + word.length <= end && index.length != 0) {
                      if (word === searchText) {
                        searchTextCountInSlice++;
                      }
                      hits.push({position: position, length: word.length});
                      var wordEnd = position + word.length;

                      // move to next position of hit

                      index.pop();
                      while (index.length != 0) {
                        item = index[index.length - 1];
                        position = item.position;
                        word = item.word;
                        if (wordEnd > position) {
                          index.pop();
                        } else {
                          break;
                        }
                      }
                    }
                    searchTextCount += searchTextCountInSlice;
                    return {
                      hits: hits,
                      start: start,
                      end: end,
                      searchTextCount: searchTextCountInSlice
                    };
                  }

                  var slicesOfTitle = [];
                  if (indexOfTitle.length != 0) {
                    slicesOfTitle.push(mergeIntoSlice(title, 0, title.length, indexOfTitle));
                  }

                  var slicesOfContent = [];
                  while (indexOfContent.length != 0) {
                    var item = indexOfContent[indexOfContent.length - 1];
                    var position = item.position;
                    var word = item.word;
                    // cut out 100 characters
                    var start = position - 20;
                    var end = position + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if (end < position + word.length) {
                      end = position + word.length;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    slicesOfContent.push(mergeIntoSlice(content, start, end, indexOfContent));
                  }

                  // sort slices in content by search text's count and hits' count

                  slicesOfContent.sort(function (sliceLeft, sliceRight) {
                    if (sliceLeft.searchTextCount !== sliceRight.searchTextCount) {
                      return sliceRight.searchTextCount - sliceLeft.searchTextCount;
                    } else if (sliceLeft.hits.length !== sliceRight.hits.length) {
                      return sliceRight.hits.length - sliceLeft.hits.length;
                    } else {
                      return sliceLeft.start - sliceRight.start;
                    }
                  });

                  // select top N slices in content

                  var upperBound = parseInt('1');
                  if (upperBound >= 0) {
                    slicesOfContent = slicesOfContent.slice(0, upperBound);
                  }

                  // highlight title and content

                  function highlightKeyword(text, slice) {
                    var result = '';
                    var prevEnd = slice.start;
                    slice.hits.forEach(function (hit) {
                      result += text.substring(prevEnd, hit.position);
                      var end = hit.position + hit.length;
                      result += '<b class="search-keyword">' + text.substring(hit.position, end) + '</b>';
                      prevEnd = end;
                    });
                    result += text.substring(prevEnd, slice.end);
                    return result;
                  }

                  var resultItem = '';

                  if (slicesOfTitle.length != 0) {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + highlightKeyword(title, slicesOfTitle[0]) + "</a>";
                  } else {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + title + "</a>";
                  }

                  slicesOfContent.forEach(function (slice) {
                    resultItem += "<a href='" + articleUrl + "'>" +
                      "<p class=\"search-result\">" + highlightKeyword(content, slice) +
                      "...</p>" + "</a>";
                  });

                  resultItem += "</li>";
                  resultItems.push({
                    item: resultItem,
                    searchTextCount: searchTextCount,
                    hitCount: hitCount,
                    id: resultItems.length
                  });
                }
              })
            };
            if (keywords.length === 1 && keywords[0] === "") {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>'
            } else if (resultItems.length === 0) {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>'
            } else {
              resultItems.sort(function (resultLeft, resultRight) {
                if (resultLeft.searchTextCount !== resultRight.searchTextCount) {
                  return resultRight.searchTextCount - resultLeft.searchTextCount;
                } else if (resultLeft.hitCount !== resultRight.hitCount) {
                  return resultRight.hitCount - resultLeft.hitCount;
                } else {
                  return resultRight.id - resultLeft.id;
                }
              });
              var searchResultList = '<ul class=\"search-result-list\">';
              resultItems.forEach(function (result) {
                searchResultList += result.item;
              })
              searchResultList += "</ul>";
              resultContent.innerHTML = searchResultList;
            }
          }

          if ('auto' === 'auto') {
            input.addEventListener('input', inputEventFunction);
          } else {
            $('.search-icon').click(inputEventFunction);
            input.addEventListener('keypress', function (event) {
              if (event.keyCode === 13) {
                inputEventFunction();
              }
            });
          }

          // remove loading animation
          $(".local-search-pop-overlay").remove();
          $('body').css('overflow', '');

          proceedsearch();
        }
      });
    }

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched === false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(onPopupClose);
    $('.popup').click(function(e){
      e.stopPropagation();
    });
    $(document).on('keyup', function (event) {
      var shouldDismissSearchPopup = event.which === 27 &&
        $('.search-popup').is(':visible');
      if (shouldDismissSearchPopup) {
        onPopupClose();
      }
    });
  </script>





  

  

  

  
  

  

  

  

<script src="/blog/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","model":{"jsonPath":"/blog/live2dw/assets/koharu.model.json"},"display":{"position":"right","width":150,"height":320},"mobile":{"show":true},"log":false,"tagMode":false});</script></body>
</html>
